/**
 * 我的资料
 * author:zhangjlt
 * date:2016年3月10日10:30:42
 */
;
define(function(require, exports, module) {
	var wechat = require("wechat");
	var advocacyCenter = {
		education: [],
		/**
		 * bindEvent 页面事件
		 */
		bindEvent: function() {
			//返回
			$("#return_comp_yuyue").unbind().on("click", function() {
				window.location.href = "#/index/yuyue";
				//window.history.back(-1);
			});
		},
		/**
		 * 进行页面路由监听配置
		 */
		bindRout: function() {
			//公共页面监听路由
			Path.map("#/index/:page_name").to(function() {
				console.log(this.params["page_name"]);
				var page_name = this.params["page_name"];
				//来自状态
				var from = "right";
				if(page_name == "my") {
					from = "left";
					//记录状态
					common.loadPage({
						pageUrl: "html/" + page_name + ".html",
						reload: true,
						from: from
					});
				} else {
					//记录状态
					common.loadPage({
						pageUrl: "html/" + page_name + ".html",
						reload: true,
						from: from
					});
				}

			});
			//公共页面监听路由
			Path.map("#home").to(function() {
				//返回首页
				common.loadPage({
					pageUrl: "html/index.html",
					reload: false,
					from: "left"
				});
			});
			//Path.root("#home");
			Path.listen();
		},
		/**
		 * 页面数据加载
		 */
		initData: function() {
			var appid = window.localStorage.getItem("appId");
			var openid = window.localStorage.getItem("openId");
			var param = {
			};
			common.loadData({
				url: "/webchat/getuserinfo?appid=" + appid + "&openid=" + openid, //"/UMPPubServlet?method=getWxUserInfo",
				param: param,
				successCallBack: function(res) {
					if(res.status == "1") {
						var headImgUrl = res.data.headImgUrl;
						$("#name_advocacyCenter").val(res.data.nickname);
						$("#abbr_advocacyCente").attr("src",headImgUrl);
						
					}else{
						common.showTip({
							content: "获取微信用户信息出错"
						});
					}
				}, //回调函数
				cache: false
			});
			var iscroll = require("iscroll");
			common.initIscroll({
				container: "iscrollContent_advocacyCenter",
				showScrollBar: false,
			});

//			var paramstr =window.localStorage.getItem("paramstr");
//			var param = JSON.parse(paramstr);
//			$("#chang_comp").text(param.chang);
//			$("#teacher_comp").text(param.teacher);
//			$("#name_comp").text(param.name);
//			$("#phone_comp").text(param.phone);
//			$("#time_comp").text(param.day+param.time);
//			$("#submit_comp").text(param.submitTime);
		},
		/**
		 * each page init mothed
		 */
		initialize: function() {
			//动态加载数据
			advocacyCenter.initData();
			//事件绑定
			advocacyCenter.bindEvent();
			//路由绑定
			advocacyCenter.bindRout();
		}
	};

	module.exports = advocacyCenter;
});